﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyChungCu_V
{
    public partial class dlgAddPeople : Form
    {
        public dlgAddPeople()
        {
            InitializeComponent();
        }
        public Guid id
        {
            get { return Guid.Parse(mtxtMa.Text); }

        }
        public string name
        {
            get { return mtxtTen.Text; }

        }

        public int age
        {
            get { return int.Parse(mtxtTuoi.Text); }

        }
        public string NgheNghiep
        {
            get { return mtxtNgheNghiep.Text; }
        }
        public string id_card_no
        {
            get { return mtxtSoCMT.Text;}

        }
       public string phone_num
        {
            get { return mtxtDienthoai.Text; }

        }
        public bool sex
        {
            get
            {
                if (sex == false)
                    return bool.Parse(rdbFemale.Text);
                else
                    return bool.Parse(rdbMale.Text);
            }

        }
        public DateTime date_of_birth
        {
            get { return DateTime.Parse(dtiNgaysinh.Text); }
        }
        public string race
        {
            get { return cboDantoc.Text; }

        }
        public string religion
        {
            get { return cboTongiao.Text; }
        }
        private void btOK_Click(object sender, EventArgs e)
        {
             
        int age;
    if (mtxtTuoi.Text.Length <= 0 )
    {
        MessageBox.Show("Enter a valid age!");
        mtxtTuoi.Select();
        return;
    }
    try
    {
        age = int.Parse(mtxtTuoi.Text);
    }
    catch (Exception)
    {
        MessageBox.Show("Enter a valid age!");
        mtxtTuoi.Select();
        return;
    }
   
 
    if (mtxtTen.Text.Length <= 0)
    {
        MessageBox.Show("Enter a valid name!");
        mtxtTen.Select();
        return;
    }
    
   
    
    if (dtiNgaysinh.Text.Length > 0)
    {
        try
        {
            
            
        }
        catch(Exception)
        {
            MessageBox.Show("Enter a valid joined date!");
            dtiNgaysinh.Select();
            return;
        }
    }
 
 
    dlgAddPeople mainForm = new dlgAddPeople();
    this.Close();

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private void dlgAddPeople_Load(object sender, EventArgs e)
        {

        }
    }
}
